<%@ page language="java" pageEncoding="utf-8"%>
<%@ page import="java.util.*"%>
<%@ page import="org.jbpm.*"%>
<%@page import="org.jbpm.graph.def.ProcessDefinition"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>login page</title>
		<script type="text/javascript">
			function addPerson()
			{
				alert("good !");
			}
			
			function fsubmit()
			{
				if(document.getElementById("chooseProcess").value == "newFlow_ECGUARD")
				{
					var persons = document.getElementsByName("firstperson");
					var personStr = "" ;
					for(var i = 0 ;i<persons.length ;i++)
					{
						personStr = personStr + persons[i].value + "," ;
					}
					document.getElementById("newFlowPersons").value = personStr ;
				}
				document.getElementsByTagName("form")[0].submit() ;
			}
		</script>
	</head>
	<body>
		<form action="<%=request.getContextPath()%>/fill.do" method="post">
			<h1>
				请填写申请表：
			</h1>
			<br>
			报销名称：
			<input type="text" name="bill_name" />
			<br>
			报销金额：
			<input type="text" name="bill_num" />
			<br>
			报销描述：
			<input type="text" name="bill_desc" />
			<br>
			<br>
			<br>
			选择流程：
			<select name="chooseProcess" id="chooseProcess">
				<%
					JbpmContext jc = JbpmConfiguration.getInstance()
							.createJbpmContext();
					List list = jc.getGraphSession().findLatestProcessDefinitions();
					if (list != null && list.size() > 0) {
						for(Object o : list){
							ProcessDefinition pd = (ProcessDefinition)o ;
				%>
					<option value="<%=pd.getName()%>">
						<%=pd.getName()%>
					</option>
				<%
						}
					}
				%>
				<option value="newFlow_ECGUARD">
					新建流程
				</option>
			</select>
			<input type="hidden" id="newFlowPersons" name="newFlowPersons" />
			<br>
			<br>
			<table bgcolor="grey">
				<tr>
					<td>
						流程名称：
						<input type="text" id="newFlowName" name="newFlowName" />
						&nbsp;&nbsp;&nbsp;
						<input type="button" value="增加审批人" onclick="addPerson()" />
					</td>
				</tr>
				<tr>
					<td>
						审批人：
						<input type="text" name="firstperson" />
					</td>
				</tr>
				<tr>
					<td>
						审批人：
						<input type="text" name="firstperson" />
					</td>
				</tr>
				<tr>
					<td>
						审批人：
						<input type="text" name="firstperson" />
					</td>
				</tr>
				<tr>
					<td>
						审批人：
						<input type="text" name="firstperson" />
					</td>
				</tr>
			</table>

			<br>
			<br>
			<input type="button" value="提交审批" onclick="fsubmit()" />
		</form>
	</body>
</html>
